﻿namespace MLSharp.Utilities
{
	/// <summary>
	/// Extension methods for doubles.
	/// </summary>
	public static class DoubleExtensions
	{
		/// <summary>
		/// Formats a double for writing to a table file.
		/// </summary>
		/// <param name="value"></param>
		/// <returns>The formatted version of the double.</returns>
		public static string FormatForWriting(this double value)
		{
			string result = value.ToString("R").Replace(",", string.Empty);

			return !result.Contains(".") ? result + ".0" : result;
		}
	}
}
